From 36e06c262bc93b816742719d23ebeebc543cbba7 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Tue, 31 Jul 2007 10:11:47 +0100 Subject: [PATCH] hvm: Define common (across VMX and SVM) set of event types. Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/svm/intr.c | 4 ++-- xen/arch/x86/hvm/svm/svm.c | 6 +++--- xen/arch/x86/hvm/vmx/intr.c | 3 ++- xen/arch/x86/hvm/vmx/vmx.c | 3 ++- xen/include/asm-x86/hvm/hvm.h | 11 +++++++++++ xen/include/asm-x86/hvm/svm/vmcb.h | 8 -------- xen/include/asm-x86/hvm/vmx/vmx.h | 13 ++++--------- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/hvm/svm/intr.c b/xen/arch/x86/hvm/svm/intr.c index c3a30b78e8..3cedb75f30 100644 --- a/xen/arch/x86/hvm/svm/intr.c +++ b/xen/arch/x86/hvm/svm/intr.c @@ -58,7 +58,7 @@ static void svm_inject_nmi(struct vcpu *v) event.bytes = 0; event.fields.v = 1; - event.fields.type = EVENTTYPE_NMI; + event.fields.type = X86_EVENTTYPE_NMI; event.fields.vector = 2; ASSERT(vmcb->eventinj.fields.v == 0); @@ -72,7 +72,7 @@ static void svm_inject_extint(struct vcpu *v, int vector) event.bytes = 0; event.fields.v = 1; - event.fields.type = EVENTTYPE_INTR; + event.fields.type = X86_EVENTTYPE_EXT_INTR; event.fields.vector = vector; ASSERT(vmcb->eventinj.fields.v == 0); diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 7b0ad0af39..4f632275ca 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -71,8 +71,8 @@ static void *root_vmcb[NR_CPUS] __read_mostly; /* hardware assisted paging bits */ extern int opt_hap_enabled; -static void svm_inject_exception(struct vcpu *v, int trap, - int ev, int error_code) +static void svm_inject_exception( + struct vcpu *v, int trap, int ev, int error_code) { eventinj_t event; struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; @@ -84,7 +84,7 @@ static void svm_inject_exception(struct vcpu *v, int trap, event.bytes = 0; event.fields.v = 1; - event.fields.type = EVENTTYPE_EXCEPTION; + event.fields.type = X86_EVENTTYPE_HW_EXCEPTION; event.fields.vector = trap; event.fields.ev = ev; event.fields.errorcode = error_code; diff --git a/xen/arch/x86/hvm/vmx/intr.c b/xen/arch/x86/hvm/vmx/intr.c index fd28603f9b..a09d0627a8 100644 --- a/xen/arch/x86/hvm/vmx/intr.c +++ b/xen/arch/x86/hvm/vmx/intr.c @@ -175,7 +175,8 @@ asmlinkage void vmx_intr_assist(void) * Clear NMI-blocking interruptibility info if an NMI delivery * faulted. Re-delivery will re-set it (see SDM 3B 25.7.1.2). */ - if ( (idtv_info_field&INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI ) + if ( (idtv_info_field&INTR_INFO_INTR_TYPE_MASK) == + (X86_EVENTTYPE_NMI << 8) ) __vmwrite(GUEST_INTERRUPTIBILITY_INFO, __vmread(GUEST_INTERRUPTIBILITY_INFO) & ~VMX_INTR_SHADOW_NMI); diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index b2af52a52d..1aff21aa22 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2965,7 +2965,8 @@ asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs) vmx_inject_hw_exception(v, TRAP_page_fault, regs->error_code); break; case TRAP_nmi: - if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) != INTR_TYPE_NMI ) + if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) != + (X86_EVENTTYPE_NMI << 8) ) goto exit_and_crash; HVMTRACE_0D(NMI, v); vmx_store_cpu_guest_regs(v, regs, NULL); diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 1482f4aaa5..6adaedad31 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -323,6 +323,17 @@ static inline int hvm_event_injection_faulted(struct vcpu *v) /* These exceptions must always be intercepted. */ #define HVM_TRAP_MASK (1U << TRAP_machine_check) +/* + * x86 event types. This enumeration is valid for: + * Intel VMX: {VM_ENTRY,VM_EXIT,IDT_VECTORING}_INTR_INFO[10:8] + * AMD SVM: eventinj[10:8] and exitintinfo[10:8] (types 0-4 only) + */ +#define X86_EVENTTYPE_EXT_INTR 0 /* external interrupt */ +#define X86_EVENTTYPE_NMI 2 /* NMI */ +#define X86_EVENTTYPE_HW_EXCEPTION 3 /* hardware exception */ +#define X86_EVENTTYPE_SW_INTERRUPT 4 /* software interrupt */ +#define X86_EVENTTYPE_SW_EXCEPTION 6 /* software exception */ + static inline int hvm_cpu_up(void) { if ( hvm_funcs.cpu_up ) diff --git a/xen/include/asm-x86/hvm/svm/vmcb.h b/xen/include/asm-x86/hvm/svm/vmcb.h index afea99d7b9..1400e81035 100644 --- a/xen/include/asm-x86/hvm/svm/vmcb.h +++ b/xen/include/asm-x86/hvm/svm/vmcb.h @@ -320,14 +320,6 @@ typedef union } fields; } __attribute__ ((packed)) eventinj_t; -enum EVENTTYPES -{ - EVENTTYPE_INTR = 0, - EVENTTYPE_NMI = 2, - EVENTTYPE_EXCEPTION = 3, - EVENTTYPE_SWINT = 4, -}; - typedef union { u64 bytes; diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h index 82938a3728..2d5670faee 100644 --- a/xen/include/asm-x86/hvm/vmx/vmx.h +++ b/xen/include/asm-x86/hvm/vmx/vmx.h @@ -94,11 +94,6 @@ void vmx_vlapic_msr_changed(struct vcpu *v); #define INTR_INFO_VALID_MASK 0x80000000 /* 31 */ #define INTR_INFO_RESVD_BITS_MASK 0x7ffff000 -#define INTR_TYPE_EXT_INTR (0 << 8) /* external interrupt */ -#define INTR_TYPE_NMI (2 << 8) /* NMI */ -#define INTR_TYPE_HW_EXCEPTION (3 << 8) /* hardware exception */ -#define INTR_TYPE_SW_EXCEPTION (6 << 8) /* software exception */ - /* * Exit Qualifications for MOV for Control Register Access */ @@ -276,7 +271,7 @@ static inline void __vmx_inject_exception( * VM entry]", PRM Vol. 3, 22.6.1 (Interruptibility State). */ - intr_fields = (INTR_INFO_VALID_MASK | type | trap); + intr_fields = (INTR_INFO_VALID_MASK | (type<<8) | trap); if ( error_code != VMX_DELIVER_NO_ERROR_CODE ) { __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code); intr_fields |= INTR_INFO_DELIVER_CODE_MASK; @@ -294,18 +289,18 @@ static inline void vmx_inject_hw_exception( struct vcpu *v, int trap, int error_code) { v->arch.hvm_vmx.vector_injected = 1; - __vmx_inject_exception(v, trap, INTR_TYPE_HW_EXCEPTION, error_code); + __vmx_inject_exception(v, trap, X86_EVENTTYPE_HW_EXCEPTION, error_code); } static inline void vmx_inject_extint(struct vcpu *v, int trap) { - __vmx_inject_exception(v, trap, INTR_TYPE_EXT_INTR, + __vmx_inject_exception(v, trap, X86_EVENTTYPE_EXT_INTR, VMX_DELIVER_NO_ERROR_CODE); } static inline void vmx_inject_nmi(struct vcpu *v) { - __vmx_inject_exception(v, 2, INTR_TYPE_NMI, + __vmx_inject_exception(v, 2, X86_EVENTTYPE_NMI, VMX_DELIVER_NO_ERROR_CODE); } -- 2.30.2